

DEFINE VARIABLE part LIKE pt_part .

DEFINE VARIABLE um LIKE pt_um .

DEFINE VARIABLE ptdesc AS CHARACTER.

DEFINE VARIABLE cost LIKE sct_cst_tot.

DEFINE STREAM bf.

DEFINE VARIABLE str AS CHARACTER.

INPUT FROM VALUE("f:\hk_src\audit\partcost.csv") .

OUTPUT STREAM bf TO VALUE("f:\hk_src\audit\pt_cost.txt").

REPEAT ON ERROR UNDO, RETRY :

    IMPORT DELIMITER "," part cost NO-ERROR .

    FIND FIRST pt_mstr NO-LOCK WHERE pt_part = SUBSTRING(part, 1, LENGTH(part) - 1) 
        OR pt_part = SUBSTRING(part, 1, LENGTH(part) - 1) + "R" NO-ERROR.

    PUT STREAM bf "@@batchload ppcsbtld.p" SKIP .

    PUT STREAM bf "yes" SKIP.

    EXPORT STREAM bf part pt_site .

    EXPORT STREAM bf "Standard" .

    EXPORT STREAM bf "material" cost .

    PUT STREAM bf "." SKIP .

    PUT STREAM bf "@@end" SKIP.

    PUT STREAM bf "@@batchload ppcsbtld.p" SKIP .

    PUT STREAM bf "yes" SKIP.

    EXPORT STREAM bf part pt_site .

    EXPORT STREAM bf "Current" .

    EXPORT STREAM bf "material" cost .

    PUT STREAM bf "." SKIP .

    PUT STREAM bf "@@end" SKIP.

END.
